<template>
  <a-col :span="4">
    <!-- 存货分类树 -->
    <CommonTree
      ref="deptTree"
      :treeOptions="treeOptions"
      @select="clickInventoryNode"
    />
  </a-col>
</template>

<script>

import CommonTree from '@/components/CommonTree'
import { projectTree } from '@/api/project/manage'

export default {
  name: 'ProjectTree',
  components: {
    CommonTree
  },
  props: {
    treeOptions: {
      type: Array,
      required: false,
      default: () => []
    }
  },
  data () {
    return {
      selectProjectId: ''
    }
  },
  created () {
    this.getInventoryCategoryTree()
  },
  methods: {
    // 查询所有数据tree
    getInventoryCategoryTree () {
      if (!this.treeOptions.length) {
        projectTree().then(res => {
          // this.treeOptions = res.data
          this.$emit('update:treeOptions', res.data)
          console.info(this.treeOptions, 'projectTree')
        })
      }
    },
    clickInventoryNode (categoryCode) {
      // this.selectProjectId = categoryCode
      this.$emit('select', categoryCode)
    }
  }
}
</script>
